package com.cherrish.demo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @author cherrish
 * @time 2019-01-11 14:11
 * @name TestList
 * @desc:
 */
public class TestList {
    public static void main(String[] args) {
//        test1();
//        test2();
//        test3();
        test4();
    }

    private static void test4(){
        String[] values = new String[]{"AA", "BB", "CC"};
        System.out.println(Arrays.asList(values).contains("AA"));
        System.out.println(Arrays.binarySearch(values, "BB"));
    }

    private static void test3(){
        List<Integer> integers1 = new ArrayList<>(3);
        Collections.addAll(integers1, 1, 2, 3);
        System.out.println(integers1);
        integers1.add(4);
        System.out.println(integers1);
    }

    private static void test2(){
        List<Integer> integers1 = Arrays.asList(1, 2, 3);
        System.out.println(integers1);

        //UnsupportedOperationException
        integers1.add(4);
        System.out.println(integers1);
    }

    private static void test1(){
        List<Integer> integers1 = new ArrayList<>(3);
        integers1.add(1);
        integers1.add(2);
        integers1.add(3);
        System.out.println(integers1);
        integers1.add(4);
        System.out.println(integers1);
    }


}
